<html>
<head><meta charset="utf-8"><title>Running rustfmt 2 in Rust-Analyzer · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html">Running rustfmt 2 in Rust-Analyzer</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226629345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629345">(Feb 17 2021 at 08:59)</a>:</h4>
<p>The author of one of the projects I work on insists on using rustfmt 2 (that is, rustfmt + cargo-fmt compiled with CFG_RELEASE=nightly and CFG_RELEASE_CHANNEL=nightly -- this is actually different from running cargo +nightly fmt in my understanding)</p>



<a name="226629444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629444">(Feb 17 2021 at 09:00)</a>:</h4>
<p>Now I have that rustfmt installed in and can basically run it as <code>PATH=~/src/rustls/target/rustfmt/bin:$PATH ./target/rustfmt/bin/cargo-fmt</code>, but I was wondering if I can somehow get RA to run that for me, via the rustfmt.overrideCommand</p>



<a name="226629485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629485">(Feb 17 2021 at 09:01)</a>:</h4>
<p>So I'm wondering, is there any way to set the path similar to this? (I think that's necessary because it's how cargo-fmt finds rustfmt)</p>



<a name="226629545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629545">(Feb 17 2021 at 09:01)</a>:</h4>
<p>the path is to trick <code>cargo-fmt</code> to pick the right one?</p>



<a name="226629605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629605">(Feb 17 2021 at 09:02)</a>:</h4>
<p>try <code>rust-analyzer.server.env</code></p>



<a name="226629633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629633">(Feb 17 2021 at 09:02)</a>:</h4>
<p>does <code>cargo fmt</code> honor <code>RUSTFMT</code> env var?</p>



<a name="226629718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629718">(Feb 17 2021 at 09:03)</a>:</h4>
<p>wait, we don't actually call <code>cargo fmt</code> ourselves, we run <code>rustfmt</code> directly. So just <code>rustmft.command</code> should help</p>



<a name="226629796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629796">(Feb 17 2021 at 09:04)</a>:</h4>
<p>(you probably want the simpler version, without override. We need better names here)</p>



<a name="226629799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629799">(Feb 17 2021 at 09:04)</a>:</h4>
<p>ah, so I just put the path to my rustfmt in <code>overrideCommand</code>?</p>



<a name="226629804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629804">(Feb 17 2021 at 09:04)</a>:</h4>
<p>ok</p>



<a name="226629817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629817">(Feb 17 2021 at 09:04)</a>:</h4>
<p>this is what I found when searching the settings</p>



<a name="226629901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629901">(Feb 17 2021 at 09:05)</a>:</h4>
<p>when I search for <code>rustfmt</code> in the VS Code settings, I only find <code>Rustfmt: Extra Args</code> and <code>Rustfmt: Override Command</code></p>



<a name="226629930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226629930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226629930">(Feb 17 2021 at 09:06)</a>:</h4>
<p>urgh, yeah, I am imagining things</p>



<a name="226630008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226630008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226630008">(Feb 17 2021 at 09:06)</a>:</h4>
<p>yay, it works</p>



<a name="226630014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226630014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226630014">(Feb 17 2021 at 09:06)</a>:</h4>
<p>awesome</p>



<a name="226630036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226630036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226630036">(Feb 17 2021 at 09:07)</a>:</h4>
<p>thanks</p>



<a name="226630052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226630052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226630052">(Feb 17 2021 at 09:07)</a>:</h4>
<p>so, yeah, you need overrideCommand (or you can also send a PR implementing <code>rust-analyzer.cargo.bin</code> and <code>rust-analyzer.rustfmt.bin</code>)</p>



<a name="226630273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226630273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226630273">(Feb 17 2021 at 09:10)</a>:</h4>
<p>I don't really want to override cargo bin, only specifically the rustfmt stuff</p>



<a name="226630320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Running%20rustfmt%202%20in%20Rust-Analyzer/near/226630320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Running.20rustfmt.202.20in.20Rust-Analyzer.html#226630320">(Feb 17 2021 at 09:10)</a>:</h4>
<p>but anyway, I'm happy now :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>